1
/****************************** Module Header ******************************\
2 * Module Name: Default.aspx.cs
3 * Project: CSASPNETuserControlEventsExpose
4 * Copyright (c) Microsoft Corporation.
6 * This page load the usercontrol and add the usercontrol into webpage.
7 * Then subscribe the MyEvent of usercontrol to react the button click of usercontrol in the webpage.
8 * When click the button of usercontrol, the webpage will display the selected value of dropdownlist.
10 * This source is subject to the Microsoft Public License.
11 * See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
12 * All other rights reserved.
14 * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
15 * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
17 \***************************************************************************/
21 namespace CSASPNETUserControlEventExpose
23 public partial class _Default
: System
.Web
.UI
.Page
25 protected void Page_Load(object sender
, EventArgs e
)
27 MyUserControl myUserControl
= LoadControl("MyUserControl.ascx") as MyUserControl
;
28 if (myUserControl
!= null)
30 myUserControl
.MyEvent
+= new MyUserControl
.MyEventHandler(userControlBtnClick
);
31 this.PlaceHolder1
.Controls
.Add(myUserControl
);
34 public void userControlBtnClick(object sender
, EventArgs e
)
36 Response
.Write("Main Page Event Handler<BR/>Selected Value:" + ddlTemp
.SelectedItem
.Text
+ "<BR/>");